import qs from 'qs'
import service from '@/api/fetch.js'

export const typewww = 'application/x-www-form-urlencoded; charset=UTF-8'

export default {
  // 添加管理员
  getSubjectList (params) {
    return service(`/sysuser/add`, params, 'POST')
  },
  // 添加管理员
  sysuserLogin (params) {
    return service(`/sysuser/login`, qs.stringify(params), 'POST', { 'Content-Type': typewww })
  },
  // 校级分页查询考生信息
  getStudentInfoList (params) {
    return service(`/student/find/school`, params, 'GET')
  },
  // 删除指定考生信息
  delStudentOne (params) {
    return service(`/student/delete/one?id=${params.id}`, '', 'POST')
  },
  // 删除学校考生信息
  delStudentAll (params) {
    return service(`/student/delete/all?schoolName=${params.schoolName}`, '', 'POST')
  },
  // 校级管理员上报考生数据
  reportingStudentData (params) {
    return service(`/student/reportingData?schoolName=${params.schoolName}`, '', 'POST')
  },
  // 新增或保存考生信息
  saveOrUpdateStudent (params) {
    return service(`/student/saveOrUpdate`, params, 'POST')
  },
  // 获取所有角色
  getALLRoles (params) {
    return service(`/sysuser/all_roles`, params, 'GET')
  },
  // 获取用户信息
  getUserInfo (params) {
    return service('/sysuser/userinfo', params, 'POST')
  },
  // 增加管理员
  createUser (params) {
    return service('/sysuser/add', qs.stringify(params), 'POST')
  },
  // 编辑管理员
  updateUser (params) {
    return service('/sysuser/edit', qs.stringify(params), 'POST')
  },
  // 用户登出
  logout (params = '') {
    return service('/sysuser/logout', params, 'POST')
  },
  // 获取用户的管辖区域
  getArea (params = '') {
    return service('/area/get_all', params, 'GET')
  },
  // 获取管理员列表
  getAdmin (params = '') {
    return service('/sysuser/search', params, 'GET')
  },
  // 设置考试时间
  setExamTime (params) {
    return service('/examPlan/batchTime', params, 'POST')
  },
  // 获取考试时间
  getExamTime (params) {
    return service('/examPlan/findBatchTime', params, 'POST')
  },
  // 修改管理员密码
  updatePassword (params) {
    return service('/sysuser/admin_change_password', qs.stringify(params), 'POST')
  },
  // 删除、禁用，解禁下级下级用户
  changeStatus (params) {
    return service('/sysuser/change_status', qs.stringify(params), 'POST')
  },
  // 重置考试时间
  resetExamTime (params) {
    return service('/examPlan/deleteBatchTime', params, 'POST')
  },
  // 按学校导出数据
  exportStudentData (params) {
    return service(`/student/export?schoolName=${params.schoolName}`, '', 'POST')
  },
  // 批量上传考生图片
  uploadPhotos (params) {
    return service(`/student/upload/photos`, params, 'POST', { 'Content-Type': 'multipart/form-data' })
  },
  // html转换成pdf
  covert2Pdf (params) {
    return service(`/ticketCard/covertToPdf`, params, 'POST')
  },
  // 分页查询准考证信息
  getTicketCartList (params) {
    return service(`/ticketCard/find/page`, params, 'GET')
  },
  // 按学校查询准考证
  getTicketCartListBySchool (params) {
    return service(`/ticketCard/find/school`, params, 'GET')
  },
  // html转换成pdf
  superviseCardCovert2Pdf (params) {
    return service(`/superviseCard/covertToPdf`, params, 'POST')
  },
  // 添加监考人员
  createStaffInvigilate (params) {
    return service(`/batchStaff/addStaffInvigilate`, params, 'POST')
  },
  // 添加候考人员
  createStaffWait (params) {
    return service(`/batchStaff/addStaffWait`, params, 'POST')
  },
  // 分页查询监考人员
  getStaffInvigilateList (params) {
    return service(`/batchStaff/findStaffInvigilate`, params, 'GET')
  },
  // 分页查询候考人员
  getStaffWaitList (params) {
    return service(`/batchStaff/findStaffWait`, params, 'GET')
  },
  // 删除候考人员信息
  delStaffInvigilate (params) {
    return service(`/batchStaff/delete/staffInvigilates?id=${params.id}`, '', 'POST')
  },
  // 删除监考人员信息
  delStaffWait (params) {
    return service(`/batchStaff/delete/staffWait?id=${params.id}`, '', 'POST')
  },
  // 查询考试时间
  getBeginBatchTime (params) {
    return service(`/examPlan/getExamDateList`, params, 'POST')
  },
  // 修改个人的用户密码
  updateInfoPassword (params) {
    return service('/sysuser/change_password', qs.stringify(params), 'POST')
  },
  // 修改个人用户信息
  updateInfo (params) {
    return service('/sysuser/edit_my_info', qs.stringify(params), 'POST')
  },
  // 查询学校的班级信息
  getClassList (params) {
    return service('/student/class', params, 'GET')
  },
  // 新增考点时显示的考试时间
  findBatchTime (params) {
    return service('/examPlan/getBatchTimeInfo', params, 'POST')
  },
  // 下载管理员模板
  downUserTemplate (params = '') {
    return service('/sysuser/download_template', params, 'GET')
  },
  // 导入候考人员信息
  // importStaffInvigilate (params) {
  //   return service(`/batchStaff/resultImport/staffInvigilates`, params, 'POST')
  // },
  // 导入监考人员信息
  // importStaffWait (params) {
  //   return service(`/batchStaff/resultImport/staffWaits`, params, 'POST')
  // }
  // 创建考点
  cerateExamSite (params) {
    return service(`/area/setAreaAsPoint?areaName=${params.areaName}&schoolName=${params.schoolName}`, '', 'POST')
  },
  // 获取考点列表
  getExamSiteList (params) {
    return service('/area/findArea', params, 'GET')
  },
  // 机构搜索
  searchSchool (params) {
    return service('/area/search', params, 'GET')
  },
  // 发布考试成绩
  publicExam (params = '') {
    return service('/examscore/publish', params, 'POST')
  },
  // 获取考试成绩
  getSchoolScore (params) {
    return service('/examscore/school_score', params, 'GET')
  },
  // 打印成绩
  printExcel (params) {
    return service('/examscore/print_excel', params, 'GET')
  },
  // 查看所有考点
  getExamRoomList (params) {
    return service(`/examRoom/findAll`, params, 'POST')
  },
  // 查看单个学校考场信息
  getExamRoomByName (params) {
    return service(`/examRoom/findBySchoolName`, params, 'GET')
  },
  // 添加考场
  createExamRoom (params) {
    if (params.id) {
      return service(`/examRoom/addExamRoom?id=${params.id}&areaName=${params.areaName}&colNum=${params.colNum}&roomName=${params.roomName}&rowNum=${params.rowNum}&seatNum=${params.seatNum}&waitName=${params.waitName}&seatDistribution=${params.seatDistribution}`, '', 'POST')
    } else {
      return service(`/examRoom/addExamRoom?areaName=${params.areaName}&colNum=${params.colNum}&roomName=${params.roomName}&rowNum=${params.rowNum}&seatNum=${params.seatNum}&waitName=${params.waitName}&seatDistribution=${params.seatDistribution}`, '', 'POST')
    }
  },
  // 删除考场
  delExamRoom (params) {
    return service(`/examRoom/deleteExamRoom?id=${params.id}`, '', 'POST')
  },
  // 创建考点回调参数
  getSchoolListByArea (params) {
    return service(`/area/searchSchoolByCountyName?areaName=${params.areaName}`, '', 'POST')
  },
  // 删除考点
  delExamSite (params) {
    return service(`/area/unsetPoint?areaName=${params.areaName}`, '', 'POST')
  },
  // 成绩搜索
  scoreSearch (params) {
    return service('/examscore/search', params, 'GET')
  },
  // 自动编排
  autoMatically (params) {
    return service('/organize/automatically', params, 'GET')
  },
  searchMatically (params) {
    return service('/organize/search/byPointAreaId', params, 'GET')
  },
  // 获取所有考点
  getPoint (params) {
    return service('/area/get_all_points', params, 'GET')
  },
  // 查询批次信息
  getManuallyByPonitAreaId (params) {
    return service('/organize/search/byPointAreaId', params, 'GET')
  },
  // 人工编排编辑计划
  manuallyOrder (params) {
    let _schoolIds = ''
    params.schoolIds.map(item => {
      _schoolIds += `&schoolIds=${item}`
    })
    return service(`/organize/manually/order?pointId=${params.pointId}${_schoolIds}`, '', 'GET')
  },
  // 人工编排初始化
  manuallyInit (params) {
    return service('/organize/manually/init', params, 'GET')
  },
  // 人工编排生成编排表
  manuallyGenerateTable (params) {
    return service('/organize/manually/generateTable', params, 'POST')
  },
  // 人工编排完成编排并录入
  manuallyComplete (params) {
    return service('/organize/manually/complete', params, 'POST')
  },
  // 分页查询监考证信息
  getSuperviseCardList (params) {
    return service('/superviseCard/find/page', params, 'GET')
  },
  // 重新自动编排
  againAutomatically (params) {
    return service('/organize/automatically/redo', params, 'GET')
  },
  // 删除区域下的编排数据
  deleteByArea (params) {
    return service('/organize/deleteByArea', params, 'GET')
  },
  // 通过考点名称获取考点下的所有考场编号（exam_room表id）
  getRoomNumByAreaName (params) {
    return service(`/batchStaff/createStaff?areaName=${params.areaName}`, '', 'POST')
  },
  // 删除考点的所有编排数据
  delManuallyByPointId (params) {
    return service('/organize/deleteByPoint', params, 'GET')
  },
  // 获取下个考生的考试信息
  getNextStudent (params) {
    return service('/mark/getNextStudent', params, 'GET')
  },
  // 获取录像
  getVideo (params) {
    return service('/mark/video', params, 'GET')
  },
  // 添加评卷老师
  addEvaluation (params) {
    return service('/sysuser/addMarkTeacher', qs.stringify(params), 'POST')
  },
  // 冻结解冻评卷老师
  changeTeacher (params) {
    return service('/sysuser/change_all_mark_teacher_status', qs.stringify(params), 'POST')
  },
  // 查询校级批次信息
  getSchoolAdminByArea (params) {
    return service('/organize/search/bySchoolAdminArea', params, 'GET')
  },
  // 上传考生的评卷结果
  updateScore (params) {
    return service(`/mark/updateScore?markInfoId=${params.markInfoId}&scoreJson=${params.scoreJson}`, null, 'POST')
  },
  // 获取当前管理员的所有未编排考点
  getOrganizePoints (params) {
    return service('/area/getOrganizePoints', params, 'GET')
  },
  // 重置评卷老师密码
  resetPassword (params) {
    return service('/sysuser/admin_reset_teacher_password', qs.stringify(params), 'POST')
  },
  // 通过区县名称查询所有监考老师
  getAllInvigilates (params) {
    return service('/superviseCard/findAllStaffInvigilatesByCountyName', params, 'GET')
  },
  // 考试人数统计数据
  getStatsData (params) {
    return service('/statis/fetchData', params, 'GET')
  },
  // 提交编排审核
  getOrganize (params) {
    return service('/section/submit/organize', params, 'GET')
  },
  // 查询上报审批请求
  getAllOrganize (params) {
    return service('/section/search/allOrganize', params, 'GET')
  },
  // 另外一个查询上报审批请求
  getSubmitAllOrganize (params) {
    return service('/section/search/OrganizeSubmitted', params, 'GET')
  },
  // 确认审核结果
  modifyOrganize (params) {
    return service('/section/modify/organize', params, 'GET')
  },
  // 获取座位信息
  getSeats (params) {
    return service('/examseat/getSeats', params, 'GET')
  },
  getAllPage(params) {
    return service('/mark/getAllPaperId', params, 'GET')
  }
}
